package com.tencet.servlet;

import com.tencet.service.Impl.WithdrawalImpl;
import com.tencet.service.Withdrawal;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: @date: 2022/7/20 23:25 A
 * @description: 提现
 */
@WebServlet("/withdrawal")
public class WithdrawalServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {


        WithdrawalImpl withdrawal = new WithdrawalImpl();
        String phone = (String) req.getSession().getAttribute("phone");

        String paypassword = req.getParameter("paypassword");
        System.out.println("paypassword = " + paypassword);
        String account_id1 = req.getParameter("account_id1");
        String card2_num = (String) req.getSession().getAttribute("card2_num");


        int money = (int) req.getSession().getAttribute("money");

        // int money = Integer.parseInt(req.getParameter("money"));

        boolean b = withdrawal.confirmPassword(paypassword, phone);

        if (b == true) {
            withdrawal.withdrawal(money, account_id1, card2_num);
            resp.getWriter().write("" + b);
        } else {
            resp.getWriter().write("" + b);

        }

    }
}